ARG REDIS_VERSION=5
FROM yiane/redis
#FROM redis:${REDIS_VERSION}

MAINTAINER <yiane@qq.com>

ARG START_PORT=6380
ENV START_PORT ${START_PORT}

ARG NODE_NUM=6
ENV NODE_NUM ${NODE_NUM}

COPY redis.conf /usr/local/etc/redis/redis.conf
COPY redis-port.conf.tmpl /usr/local/etc/redis/redis-port.conf.tmpl
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY create-cluster.sh /usr/local/bin/create-cluster.sh

ARG REDIS_AUTH=123456
ENV REDIS_AUTH ${REDIS_AUTH}

VOLUME ["/data/redis","/var/log/redis"]

# 初始创建
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/create-cluster.sh \
&& sed -i "s/requirepass foobared/requirepass ${REDIS_AUTH}/" /usr/local/etc/redis/redis.conf \
&& sed -i "s/masterauth foobared/masterauth ${REDIS_AUTH}/" /usr/local/etc/redis/redis.conf \
&& bash /usr/local/bin/create-cluster.sh

ENTRYPOINT ["docker-entrypoint.sh"]


# 默认启动服务
CMD ["redis-cluster", "start"]
